package com.metagurukul.metaspace.validator;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Validator {
	private Pattern pattern;
	private Matcher matcher;

	private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
	public Validator() {
	}

	/**
	 * emptyValidate value with empty value
	 * 
	 * @param value
	 *            value for validation
	 * @return true valid value, false invalid value
	 */
	public boolean validateEmpty(String value) {

		if ("".equals(value)) {
			return false;
		}
		return true;
	}

	/**
	 * emptyValidate value with empty value
	 * 
	 * @param value
	 *            value for validation
	 * @return true valid value, false invalid value
	 */
	public boolean validateEmpty(int value) {

		if (value == 0) {
			return false;
		}
		return true;

	}

	/**
	 * emailValidate value with email regular expression
	 * 
	 * @param value
	 *            value for validation
	 * @return true valid value, false invalid value
	 */
	public boolean validateEmail(String value) {

		pattern = Pattern.compile(EMAIL_PATTERN);
		matcher = pattern.matcher(value);
		return matcher.matches();

	}

}
